﻿using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Pyramid.Extentions;

namespace Pyramid.Models
{
	public class Article
	{
		[Display(Name = "序号")]
		public int Id { get; set; }

		[Display(Name = "标题")]
		[MaxLength(50)]
		[Required]
		public string Title { get; set; }

		[Display(Name = "摘要")]
		[Required]
		[MaxLength(200)]
		public string Summary { get; set; }

		[Display(Name = "内容")]
		[Required]
		[Column(TypeName = "ntext")]
		[MaxLength]
		public string Content { get; set; }

		[Display(Name = "创建时间")]
		public DateTime CreateTime { get; set; }

		[Display(Name = "创建人")]
		[MaxLength(20)]
		[Required]
		public string CreateUserId { get; set; }

		[Display(Name = "更新时间")]
		public DateTime EditTime { get; set; }

		[Display(Name = "修改人")]
		[MaxLength(20)]
		[Required]
		public string EditUserId { get; set; }

		[Display(Name = "所属频道")]
		public int ChannelId { get; set; }

		[Display(Name = "状态")]
		public int Status { get; set; }

		[NotMapped]
		public ArticleStatus StatusEnum{get { return (ArticleStatus) Status; }}

		[NotMapped]
		public string StatusString{get { return StatusEnum.ToDescription(); }}

		[ForeignKey("ChannelId")]
		public virtual Channel Channel { get; set; }
	}
}